from pydantic import BaseModel
from typing import List

# keepLogin 值可以为None，为None默认token有效期为WEB_TOKEN_DRUATION
# 为负数则是永久保持登陆
# 为正数则是7天
class LoginParam(BaseModel):
    username: str
    password: str
    keep: int = None
    
class RegisterParam(BaseModel):
    username: str
    password: str
    nickname: str
    
class UpdateUserInfoParam(BaseModel):
    userId: int = 0
    nickname: str = None
    password: str = None
    avatar: str = None
    
class CreateGroupParam(BaseModel):
    groupName: str
    userId: int = 0
    
class DeleteGroupParam(BaseModel):
    userId: int = 0
    groupId: int
    
class QueryGroupParam(BaseModel):
    userId: int = 0
    groupId: int
    
class GroupInvataionParam(BaseModel):
    userId: int = 0
    groupId: int   
    permission: int
    
class CheckInvatationParam(BaseModel):
    userId: int = 0
    signature: str
    
class QueryHubsParam(BaseModel):
    groupId: int
    
class CreateHubParam(BaseModel):
    groupId: int
    hubName: str
    description: str
    chunkSize: int = 500
    overlap: int = 100
    
class DeleteHubParam(BaseModel):
    hubId: int

class QueryHubParam(BaseModel):
    hubId: int 
    
class CreateDatabaseParam(BaseModel):
    hubId: int
    ip: str
    port: int
    type: str
    database: str
    username: str
    password: str

class  QueryDatabasesParam(BaseModel):
    hubId: int
    
class QueryFilesParam(BaseModel):
    hubId: int

class ReloadFileParam(BaseModel):
    fileId: int
    hubId:int
    
class FileReloadParam(BaseModel):
    fileId: int

class ReferenceItemParam(BaseModel):
    file_id: int
    file_name: str
    content: str   
    page_number: int
    distance: float

class MessageItem(BaseModel):
    role: str # AI HUMAN SYSTEM, When knowledge chat is select and the role is AI, the reference will have contain the reference list  
    message: str
    reference: List[ReferenceItemParam] = None
    
    
class PuttyChatParam(BaseModel):
    history: List[MessageItem]
    question: str
    llm: str = "ChatGLM3-6B" #默认本地大模型
    temperature: float = 0.5 # 默认0.5

class KnowledgeChatParam(BaseModel):
    history: List[MessageItem]
    question: str
    useReference: bool = False 
    referenceCount: int = 3 
    referencePadding: int = 1
    llm: str = "ChatGLM3-6B" #默认本地大模型
    hubId: int = -1 # 当个hubId 变成 -1时， 知识库问答变成普通问答
    temperature: float = 0.5 # 默认0.5

# 不支持上下文
class SQLChatParam(BaseModel):
    question: str
    databaseId: int # 不支持原生问答
    llm: str = "ChatGLM3-6B" #默认本地大模型
    temperature: float = 0.5 # 默认0.5